package com.example.chat.mapper;

import com.example.chat.entity.ChatMessage;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author qwert
 * @version 1.0.0
 * @create 2025/7/6 16:13
 **/
@Mapper
public interface ChatMessageMapper {
    @Insert("""
insert into chat_message (message_id, chat_id, sender, type, content, create_time, update_time, operator_id, is_delete) 
values (#{messageId}, #{chatId}, #{sender}, #{type}, #{content}, now(), now(), null, 0)
""")
    void saveChatMessage(ChatMessage chatMessage);

    @Select("""
select * from chat_message where chat_id = #{chatId}
""")
    List<ChatMessage> getChatMessageByChatId(String chatId);
}
